<% if @drafts && @drafts.count > 0 %>
  <h2>Draft Blog Posts</h2>

  <table class="list posts drafts" summary="List of all draft blog posts">
    <%= Thoth::MainController.render_view('util/table_sortheader') %>
    <tfoot></tfoot>
    <tbody>
      <% row = 'even' %>
      <% @drafts.all do |draft| %>
        <tr class="<%= row == 'even' ? row = 'odd' : row = 'even' %>">
          <td class="id"><%= draft.id %></td>
          <td class="title">
            <a href="<%== Thoth::PostController.r(:edit, draft.id) %>#post-form"><%== draft.title %></a>
          </td>
          <td class="created">
            <%= draft.created_at(Thoth::Config.timestamp['short']) %>
          </td>
          <td class="updated">
            <%= draft.updated_at(Thoth::Config.timestamp['short']) %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>

<h2>Published Blog Posts</h2>

<%= Thoth::MainController.render_view('util/pager') %>

<table class="list posts" summary="List of all published blog posts">
  <%= Thoth::MainController.render_view('util/table_sortheader') %>
  <tfoot></tfoot>
  <tbody>
    <% row = 'even' %>
    <% @posts.all do |post| %>
      <tr class="<%= row == 'even' ? row = 'odd' : row = 'even' %>">
        <td class="id"><%= post.id %></td>
        <td class="title">
          <a href="<%== post.url %>"><%== post.title %></a>
        </td>
        <td class="created">
          <%= post.created_at(Thoth::Config.timestamp['short']) %>
        </td>
        <td class="updated">
          <%= post.updated_at(Thoth::Config.timestamp['short']) %>
        </td>
      </tr>
    <% end %>

    <% if @pager.record_count == 0 %>
      <tr class="empty">
        <td colspan="4">
          No blog posts to display.
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= Thoth::MainController.render_view('util/pager') %>
